package adsf.adminisadsf.gugedianzishichang.holder;


import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import adsf.adminisadsf.gugedianzishichang.R;
import adsf.adminisadsf.gugedianzishichang.utils.UIUtils;

/**
 * Created by administrator on 17/5/14.
 */

public class MoreHodel extends BaseHolder<Integer> {

    //加载更多的几种状态
    //分三种  加载更多  加载失败  没有更多数据
    public static final int STATE_MORE_MORE = 1;
    public static final int STATE_MORE_ERROR = 2;
    public static final int STATE_MORE_NONE = 3;

    private LinearLayout llLoadMore;
    private TextView tvLoadError;

    public MoreHodel (boolean haseMore)
    {
        //如果有更多数据,会将数传递给父类,父类同时刷新界面.最后还是会传递给refreshView来刷新界面
        if (haseMore)
        {
            setData(STATE_MORE_MORE);
        }else
        {
            setData(STATE_MORE_NONE);
        }
    }


    @Override
    public View initView() {

        View view = UIUtils.inflate(R.layout.list_item_more);
        llLoadMore = (LinearLayout) view.findViewById(R.id.ll_load_more);
        tvLoadError = (TextView) view.findViewById(R.id.tv_load_error);
        return view;
    }

    @Override
    public void refreshView(Integer data)
    {
        switch (data)
        {
            case STATE_MORE_MORE://更多
                llLoadMore.setVisibility(View.VISIBLE);
                tvLoadError.setVisibility(View.GONE);
                break;
            case STATE_MORE_NONE:
                llLoadMore.setVisibility(View.GONE);
                tvLoadError.setVisibility(View.GONE);
                break;
            case STATE_MORE_ERROR:
                llLoadMore.setVisibility(View.GONE);
                tvLoadError.setVisibility(View.VISIBLE);
                break;
        }

    }

}
